<script setup>
let props = defineProps({
  popupContent: {
    type: Object,
    required: true
  }
});
const Jump = item => {
  // 打开新标签页
  window.open(`./listNewsDetail?id=${item['id']}&from=${item['ext']['type']}`);
};
const ShowTitle = (title) => {
  if (title === 'school') {
    return '扎根学校';
  } else if (title === 'workstation') {
    return '工作站';
  } else {
    return '';
  }
};
</script>

<template>
  <div class="popup-container" v-if="popupContent.subjectId">
    <div v-if="popupContent.allEmpty" class="title">{{ popupContent.name }}</div>
    <div v-else v-for="title in popupContent.title">
      <div v-if="(popupContent[title]?.length ?? 0) > 0" class="title">{{ popupContent.name }}{{ ShowTitle(title) }}：</div>
      <div class="school-item" v-for="(item, index) in popupContent[title]" :key="index">
        <a href="javascript:void(0)" @click.prevent="Jump(item)" title="点击查看详情">
          {{ item['title'] }}
        </a>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.popup-container {
  font-size: 20px;
  line-height: 35px;

  .school-item {
    font-size: 14px;
    line-height: 26px;
  }
}
</style>
